From 12fe4b9cbbae7f90c29b714cf7381283ab1ecb22 Mon Sep 17 00:00:00 2001 From: "cl349@freefall.cl.cam.ac.uk" Date: Wed, 4 Aug 2004 17:05:13 +0000 Subject: [PATCH] bitkeeper revision 1.1144.2.1 (41111749FSr1gr4vfGeXBFEKdMTxNw) Allow a dom0 kernel to run as domU. --- .../arch/xen/i386/kernel/setup.c | 32 +++++++++----- .../arch/xen/i386/mm/init.c | 6 ++- .../drivers/xen/console/console.c | 11 +++++ .../include/asm-xen/asm-i386/fixmap.h | 2 + .../include/asm-xen/asm-i386/io.h | 42 +++++++++++++++++-- 5 files changed, 79 insertions(+), 14 deletions(-) diff --git a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c index e2fea04403..27a3e4f192 100644 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/kernel/setup.c @@ -924,7 +924,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat { int i; -#ifdef CONFIG_XEN_PHYSDEV_ACCESS +#ifdef CONFIG_XEN_PRIVILEGED_GUEST probe_roms(); #endif for (i = 0; i < e820.nr_map; i++) { @@ -1215,15 +1215,6 @@ void __init setup_arch(char **cmdline_p) register_memory(max_low_pfn); -#ifdef CONFIG_VT -#if defined(CONFIG_VGA_CONSOLE) - if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) - conswitchp = &vga_con; -#elif defined(CONFIG_DUMMY_CONSOLE) - conswitchp = &dummy_con; -#endif -#endif - /* If we are a privileged guest OS then we should request IO privs. */ if (start_info.flags & SIF_PRIVILEGED) { dom0_op_t op; @@ -1234,6 +1225,27 @@ void __init setup_arch(char **cmdline_p) panic("Unable to obtain IOPL, despite SIF_PRIVILEGED"); current->thread.io_pl = 1; } + + if (start_info.flags & SIF_INITDOMAIN) { + if (!(start_info.flags & SIF_PRIVILEGED)) + panic("Xen granted us console access " + "but not privileged status"); + +#ifdef CONFIG_VT +#if defined(CONFIG_VGA_CONSOLE) + if (!efi_enabled || + (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) + conswitchp = &vga_con; +#elif defined(CONFIG_DUMMY_CONSOLE) + conswitchp = &dummy_con; +#endif +#endif + } else { +#if defined(CONFIG_VGA_CONSOLE) + /* disable VGA driver */ + ORIG_VIDEO_ISVGA = VIDEO_TYPE_VLFB; +#endif + } } #include "setup_arch_post.h" diff --git a/linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c b/linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c index 37c3b8ec25..779a25073d 100644 --- a/linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c +++ b/linux-2.6.7-xen-sparse/arch/xen/i386/mm/init.c @@ -502,7 +502,11 @@ void __init paging_init(void) #ifdef CONFIG_XEN_PRIVILEGED_GUEST /* Setup mapping of lower 1st MB */ for (i = 0; i < NR_FIX_ISAMAPS; i++) - set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE); + if (start_info.flags & SIF_PRIVILEGED) + set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE); + else + set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i, + virt_to_machine(empty_zero_page)); #endif } diff --git a/linux-2.6.7-xen-sparse/drivers/xen/console/console.c b/linux-2.6.7-xen-sparse/drivers/xen/console/console.c index f6c2e64790..368e437be4 100644 --- a/linux-2.6.7-xen-sparse/drivers/xen/console/console.c +++ b/linux-2.6.7-xen-sparse/drivers/xen/console/console.c @@ -45,6 +45,10 @@ static enum { XC_OFF, XC_DEFAULT, XC_TTY, XC_SERIAL } xc_mode = XC_DEFAULT; static int __init xencons_setup(char *str) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) + if (str[0] == '=') + str++; +#endif if ( !strcmp(str, "tty") ) xc_mode = XC_TTY; else if ( !strcmp(str, "ttyS") ) @@ -160,7 +164,14 @@ void xen_console_init(void) else { if ( xc_mode == XC_DEFAULT ) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && defined(CONFIG_VT) + /* On a kernel built with VT support, default to serial + * console because the VT driver has already allocated the + * /dev/tty device nodes */ + xc_mode = XC_SERIAL; +#else xc_mode = XC_TTY; +#endif kcons_info.write = kcons_write; } diff --git a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h index 75bc078ec0..0bfb839f20 100644 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/fixmap.h @@ -98,6 +98,8 @@ extern void __set_fixmap_ma (enum fixed_addresses idx, __set_fixmap(idx, phys, PAGE_KERNEL) #define set_fixmap_ma(idx, phys) \ __set_fixmap_ma(idx, phys, PAGE_KERNEL) +#define set_fixmap_ma_ro(idx, phys) \ + __set_fixmap_ma(idx, phys, PAGE_KERNEL_RO) /* * Some hardware wants to get fixmapped without caching. */ diff --git a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h index 8701bcc5ce..5b6604b696 100644 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/io.h @@ -285,8 +285,15 @@ static inline void flush_write_buffers(void) #ifdef SLOW_IO_BY_JUMPING #define __SLOW_DOWN_IO "jmp 1f; 1: jmp 1f; 1:" -#else +#elif defined(__UNSAFE_IO__) #define __SLOW_DOWN_IO "outb %%al,$0x80;" +#else +#define __SLOW_DOWN_IO "\n1: outb %%al,$0x80\n" \ + "2:\n" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".long 1b,2b\n" \ + ".previous" #endif static inline void slow_down_io(void) { @@ -320,7 +327,7 @@ static inline unsigned type in##bwl##_quad(int port, int quad) { \ static inline unsigned type in##bwl(int port) { \ return in##bwl##_quad(port, 0); \ } -#else +#else #define __BUILDIO(bwl,bw,type) \ static inline void out##bwl(unsigned type value, int port) { \ out##bwl##_local(value, port); \ @@ -331,7 +338,8 @@ static inline unsigned type in##bwl(int port) { \ #endif -#define BUILDIO(bwl,bw,type) \ +#if __UNSAFE_IO__ +#define ____BUILDIO(bwl,bw,type) \ static inline void out##bwl##_local(unsigned type value, int port) { \ __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); \ } \ @@ -339,7 +347,35 @@ static inline unsigned type in##bwl##_local(int port) { \ unsigned type value; \ __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); \ return value; \ +} +#else +#define ____BUILDIO(bwl,bw,type) \ +static inline void out##bwl##_local(unsigned type value, int port) { \ + __asm__ __volatile__("1: out" #bwl " %" #bw "0, %w1\n" \ + "2:\n" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".long 1b,2b\n" \ + ".previous" : : "a"(value), "Nd"(port)); \ } \ +static inline unsigned type in##bwl##_local(int port) { \ + unsigned type value; \ + __asm__ __volatile__("1:in" #bwl " %w1, %" #bw "0\n" \ + "2:\n" \ + ".section .fixup,\"ax\"\n" \ + "3: mov" #bwl " $~0,%" #bw "0\n\t" \ + "jmp 2b\n" \ + ".previous\n" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".long 1b,3b\n" \ + ".previous" : "=a"(value) : "Nd"(port)); \ + return value; \ +} +#endif + +#define BUILDIO(bwl,bw,type) \ +____BUILDIO(bwl,bw,type) \ static inline void out##bwl##_local_p(unsigned type value, int port) { \ out##bwl##_local(value, port); \ slow_down_io(); \ -- 2.30.2